<?php

class Db_Tables2_BDictContractStatus
{
	function __construct() {
		$this->dealers_db = Zend_Registry::get("dealers_db");
	}
	
	function GetStatuses()
	{
		$result = array();
		
		$select = $this->dealers_db->select();
		$select->from("b_dict_contract_status", array("status_id", "status_name"));
		$select->where("status = ?", 1);
		$select->order("sequence");
		$data = $this->dealers_db->fetchAll($select);
		
		if(!empty($data))
		{
			foreach($data as $d)
			{
				$result[$d['status_id']] = $d['status_name'];
			}
		}
		
		return $result;
	}
	
	function GetStatusName($status_id)
	{
		$result = "";
		
		$select = $this->dealers_db->select();
		$select->from("b_dict_contract_status", array("status_name"));
		$select->where("status_id = ?", $status_id);
		$data = $this->dealers_db->fetchRow($select);
		
		if($data)
		{
			$result = $data['status_name'];
		}
		
		return $result;
	}
}